<template>
	<view class="cart-container">
		<!-- 操作按钮区 - 移动到顶部 -->
		<view class="action-buttons" v-if="cartItems.length > 0">
			<view class="btn-outline" @tap="exportToExcel">
				导出表格
			</view>
			<view class="btn-outline" @tap="shareCart">
				分享货盘
			</view>
			<view class="btn-outline" @tap="placeOrder">
				立即下单
			</view>
		</view>
		
		<view class="cart-list" v-if="cartItems.length > 0">
			<view class="cart-item" v-for="(item, index) in cartItems" :key="index" @tap="goToProductDetail(item.product.id)">
				<!-- 自定义复选框替代原生checkbox -->
				<view class="custom-checkbox" :class="{'selected': item.selected}" @tap.stop="toggleSelect(index)"></view>
				
				<!-- 左侧预览图 -->
				<image :src="item.product.preview_image_url || '/static/empty-image.png'" mode="aspectFit" class="product-image" @tap.stop="previewImage(item.product.preview_image_url)"></image>
				
				<!-- 中间信息区域 -->
				<view class="product-detail">
					<text class="product-name">{{item.product.name}}</text>
					<view class="price-container">
						<text class="price-label">售价</text>
						<text class="separator">|</text>
						<text class="product-price">{{item.salePrice || item.price}} 元</text>
					</view>
					<view class="code-container">
						<text class="code-label">编号</text>
						<text class="separator">|</text>
						<text class="product-code">{{item.skuCode||"暂无"}}</text>
					</view>
				</view>
				
				<view class="delete-btn" @tap.stop="removeItem(index)">×</view>
			</view>
		</view>
		<view class="empty-cart" v-else>
			<text class="empty-text">货盘是空的</text>
			<view class="go-shopping-btn" @tap="goShopping">去挑选商品</view>
		</view>
		
		<view class="cart-footer" v-if="cartItems.length > 0">
			<view class="select-all">
				<checkbox :checked="isAllSelected" @tap="toggleSelectAll" color="#F3B250"></checkbox>
				<text>全选</text>
			</view>
			<view class="total-info">
				<text>合计：</text>
				<text class="total-price">¥{{totalPrice}}</text>
			</view>
			<button class="btn-outline checkout-btn" @tap="checkout">结算({{selectedCount}})</button>
		</view>
		
		<!-- 加载中提示 -->
		<uni-popup ref="loadingPopup" type="center" :mask-click="false">
			<view class="loading-box">
				<view class="loading-spinner"></view>
				<text class="loading-text">{{loadingText}}</text>
			</view>
		</uni-popup>
		
		<!-- 分享弹窗 -->
		<uni-popup ref="sharePopup" type="bottom" @close="closeSharePopup" :safe-area="false">
			<view class="share-popup">
				<button open-type="share" class="share-action-btn">发送给朋友</button>
				<view class="share-action-btn" @tap="closeSharePopup">取消</view>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>

import { onShareAppMessage } from '@dcloudio/uni-app'
onShareAppMessage(() => {
  return { title: 'hello' }
})
// Removed onShareAppMessage implementation as it's moved to the methods section

</script>

<script>
	import { cartApi } from '../../api/index.js';
	import config from '../../utils/config.js';
	import auth from '../../utils/auth.js';

	export default {
		data() {
			return {
				cartItems: [],
				isLoading: false,
				shareLink: '', // 保存分享链接
				lastSharedId: '', // 保存最近一次分享的ID
				orderId: '', // 保存订单ID
				loadingText: '加载中...', // 加载提示文本
				_shareId: '', // 用于分享的ID
				_previewImage: '', // 用于分享的预览图
				_shareTitle: '', // 用于分享的标题
				showSharePopup: false,
				shareId: '',
			}
		},
		computed: {
			isAllSelected() {
				return this.cartItems.length > 0 && this.cartItems.every(item => item.selected)
			},
			totalPrice() {
				return this.cartItems.reduce((total, item) => {
					return total + (item.selected ? (item.salePrice || item.price) : 0)
				}, 0).toFixed(2)
			},
			selectedCount() {
				return this.cartItems.filter(item => item.selected).length
			}
		},
		onShow() {
			// 每次页面显示时加载购物车数据
			this.getCartList();
			auth.checkLogin();

			// 检查缓存中是否有最近分享的ID
			try {
				const cachedSharedId = uni.getStorageSync('lastSharedCartId');
				if (cachedSharedId) {
					this.lastSharedId = cachedSharedId;
				}
			} catch (e) {
				console.error('读取缓存分享ID失败', e);
			}
		},
		onShareAppMessage() {
			// 分享到微信聊天
			console.log('Sharing with ID:', this._shareId);
			

			return {
				title: this._shareTitle || '查看我的珠宝货盘',
				path: `/pages/cart/shared-cart?shareId=${this._shareId || ''}`,
				imageUrl: this._previewImage || '/static/share-default.png',
				success: () => {
					uni.showToast({
						title: '分享成功',
						icon: 'success'
					});
				},
				fail: () => {  
					uni.showToast({  
						title: '分享失败',  
						icon: 'none'  
					});
				}  
			};
		},
		methods: {
			async getCartList() {
				this.isLoading = true;
				uni.showLoading({ title: '加载中...' });
				
				try {
					const result = await cartApi.getCartList();
					
					if (result && result.data) {
						// 处理返回的购物车数据
						this.cartItems = result.data.map(item => {
							return {
								...item,
								selected: true
							};
						});
						
						// 数据加载完成后自动准备分享信息
						if (this.cartItems.length > 0) {
							// 注释掉，暂时不需要
							// this.prepareShareForMenu();
						}
					} else {
						this.cartItems = [];
					}
					
					uni.hideLoading();
					this.isLoading = false;
				} catch (error) {
					console.error('获取购物车列表失败', error);
					uni.hideLoading();
					this.isLoading = false;
					
					uni.showToast({
						title: error.message || '获取列表失败',
						icon: 'none'
					});
				}
			},
			toggleSelect(index) {
				// 更新选中状态
				this.cartItems[index].selected = !this.cartItems[index].selected;
			},
			toggleSelectAll() {
				const newStatus = !this.isAllSelected;
				this.cartItems.forEach(item => {
					item.selected = newStatus;
				});
			},
			async removeItem(index) {
				const item = this.cartItems[index];
				
				uni.showModal({
					title: '确认删除',
					content: '确定要从货盘中移除此商品吗？',
					success: async (res) => {
						if (res.confirm) {
							try {
								await cartApi.removeFromCart(item.id);
								this.cartItems.splice(index, 1);
								
								uni.showToast({
									title: '已移除',
									icon: 'success'
								});
							} catch (error) {
								uni.showToast({
									title: error.message || '删除失败',
									icon: 'none'
								});
							}
						}
					}
				});
			},
			// 导出Excel功能
			async exportToExcel() {
				if (this.cartItems.length === 0) {
					uni.showToast({
						title: '货盘为空，无法导出',
						icon: 'none'
					});
					return;
				}
				
				const selectedItems = this.cartItems.filter(item => item.selected);
				if (selectedItems.length === 0) {
					uni.showToast({
						title: '请选择要导出的商品',
						icon: 'none'
					});
					return;
				}
				
				this.loadingText = '正在生成Excel...';

				this.$refs.loadingPopup.open();
				
				try {

					// 调用导出API
					const result = await cartApi.exportToExcel({
						cartItemIds: selectedItems.map(item => item.id)
					});
					
					this.$refs.loadingPopup.close();

					
					if (result && result.data && result.data.fileID) {
						let fileID = result.data.fileID;
						
						// 在小程序环境下，直接下载并打开文件
						uni.showModal({
							title: 'Excel文件已生成',
							content: '是否下载并打开Excel文件？',
							confirmText: '下载',
							success: (res) => {
								if (res.confirm) {
									this.downloadAndOpenFile(fileID);
								}
							}
						});
						
						
						uni.showToast({
							title: 'Excel已导出',
							icon: 'success'
						});
						
					} else {
						throw new Error('导出失败');
					}
				} catch (error) {
					this.$refs.loadingPopup.close();
					uni.showToast({
						title: error.message || '导出失败',
						icon: 'none'
					});
				}
			},
			
			// 获取应用基础URL
			getAppBaseUrl() {
				const apiUrl = config.baseUrl;
				// 提取域名 (例如 http://example.com/api 变为 http://example.com)
				const domainMatch = apiUrl.match(/(https?:\/\/[^\/]+)/);
				if (domainMatch && domainMatch[1]) {
					console.log(domainMatch[1]);
					return domainMatch[1];
				}
			},
			
			// 为顶部菜单的分享功能准备分享ID
			async prepareShareForMenu() {
				// 不要显示加载提示，后台静默生成
				if (this.cartItems.length === 0) {
					console.log('购物车为空，无法准备分享ID');
					return;
				}
				
				const selectedItems = this.cartItems.filter(item => item.selected);
				if (selectedItems.length === 0) {
					console.log('没有选中商品，无法准备分享ID');
					return;
				}
				
				try {
					// 静默调用API生成分享链接
					const result = await cartApi.createShareLink({
						cartItemIds: selectedItems.map(item => item.id)
					});
					
					if (result && result.data && result.data.shareId) {
						// 保存分享ID和信息，但不显示UI反馈
						this.lastSharedId = result.data.shareId;
						const host = this.getAppBaseUrl();
						const fullShareLink = `${host}/pages/cart/shared-cart?shareId=${result.data.shareId}`;
						this.shareLink = fullShareLink;
						
						// 保存到本地缓存
						try {
							uni.setStorageSync('lastSharedCartId', result.data.shareId);
						} catch (e) {
							console.error('缓存分享ID失败', e);
						}
						
						// 设置分享参数
						this.prepareForShare(result.data.shareId, selectedItems);
						console.log('已自动准备分享ID:', result.data.shareId);
					}
				} catch (error) {
					console.error('自动准备分享ID失败', error);
					// 出错时不进行UI反馈，静默失败
				}
			},
			
			// 生成分享ID - 用于显式分享操作
			async generateShareId(selectedItems) {
				// 如果没有传入selectedItems，使用当前选中的商品
				if (!selectedItems) {
					if (this.cartItems.length === 0) {
						uni.showToast({
							title: '货盘为空，无法分享',
							icon: 'none'
						});
						return null;
					}
					
					selectedItems = this.cartItems.filter(item => item.selected);
					if (selectedItems.length === 0) {
						uni.showToast({
							title: '请选择要分享的商品',
							icon: 'none'
						});
						return null;
					}
				}
				
				// 显示加载提示
				this.loadingText = '生成分享链接...';
				this.$refs.loadingPopup.open();

				try {
					// 调用分享API
					const result = await cartApi.createShareLink({
						cartItemIds: selectedItems.map(item => item.id)
					});
					
					if (result && result.data) {
						// 处理API返回结果
						let fullShareLink = '';
						
						// 如果API返回了shareId，构建完整URL
						if (result.data.shareId) {
							this.lastSharedId = result.data.shareId; // 保存shareId供后续使用
							const host = this.getAppBaseUrl();
							fullShareLink = `${host}/pages/cart/shared-cart?shareId=${result.data.shareId}`;
							this.shareLink = fullShareLink;
							
							// 保存到本地缓存，以便在下次打开时仍能使用
							try {
								uni.setStorageSync('lastSharedCartId', result.data.shareId);
							} catch (e) {
								console.error('缓存分享ID失败', e);
							}
							
							return {
								shareId: result.data.shareId,
								shareLink: fullShareLink
							};
						}
					}
					
					throw new Error('生成分享链接失败');
				} catch (error) {
					console.error('生成分享ID失败', error);
					throw error;
				}
			},
			
			// 分享货盘功能
			async shareCart() {
				try {
					// 调用生成分享ID的方法
					const shareResult = await this.generateShareId();
					this.$refs.loadingPopup.close();
					
					if (!shareResult || !shareResult.shareId) {
						throw new Error('生成分享链接失败');
					}
					
					// 预设分享参数
					this.prepareForShare(shareResult.shareId, this.cartItems.filter(item => item.selected));
					console.log("shareResult.shareId")
					console.log(shareResult.shareId)

					// 保存shareId并显示分享弹窗
					this.shareId = shareResult.shareId;
					this.$refs.sharePopup.open(); // 使用open方法打开弹窗
				} catch (error) {
					this.$refs.loadingPopup.close();
					uni.showToast({
						title: error.message || '分享失败',
						icon: 'none'
					});
				}
			},
			
			// 准备分享数据
			prepareForShare(shareId, selectedItems) {
				this._shareId = shareId;
				this._previewImage = selectedItems.length > 0 && selectedItems[0].product.preview_image_url 
					? selectedItems[0].product.preview_image_url 
					: '/static/share-default.png';
				this._shareTitle = `查看我的珠宝货盘 (${selectedItems.length}件商品)`;
			},
			
			// 查看分享的货盘页面
			viewSharedCart(shareId) {
				if (!shareId) {
					shareId = this.lastSharedId;
				}
				
				if (!shareId) {
					uni.showToast({
						title: '分享ID不存在',
						icon: 'none'
					});
					return;
				}
				
				// 只有当不是从generateShareId调用时才需要保存
				// 如果是从其他地方直接调用，比如点击"查看已分享的货盘"按钮
				if (shareId !== this.lastSharedId) {
					// 保存到本地缓存，以便在下次打开时仍能使用
					try {
						uni.setStorageSync('lastSharedCartId', shareId);
						this.lastSharedId = shareId;
					} catch (e) {
						console.error('缓存分享ID失败', e);
					}
				}
				
				// 添加标记，防止循环导航
				const currentPages = getCurrentPages();
				const currentRoute = currentPages[currentPages.length - 1].route;
				
				// 如果当前已经在shared-cart页面，检查是否是同一个shareId
				if (currentRoute === 'pages/cart/shared-cart') {
					const currentPage = currentPages[currentPages.length - 1];
					// 如果是同一个shareId，不再重复导航
					if (currentPage.$vm.shareId === shareId) {
						console.log('已经在相同的分享页面，不再重复导航');
						return;
					}
				}
				
				console.log('导航到分享页面，shareId:', shareId);
				uni.navigateTo({
					url: `/pages/cart/shared-cart?shareId=${shareId}`
				});
			},
			
			// 提交订单功能
			async placeOrder() {
				if (this.cartItems.length === 0) {
					uni.showToast({
						title: '货盘为空，无法下单',
						icon: 'none'
					});
					return;
				}
				
				const selectedItems = this.cartItems.filter(item => item.selected);
				if (selectedItems.length === 0) {
					uni.showToast({
						title: '请选择要下单的商品',
						icon: 'none'
					});
					return;
				}
				
				// 提示用户填写备注信息
				uni.showModal({
					title: '填写订单备注',
					editable: true,
					placeholderText: '请输入您的特殊需求或备注信息',
					success: async (res) => {
						if (res.confirm) {
							const remarks = res.content || '';
							
							this.loadingText = '正在提交订单...';
							this.$refs.loadingPopup.open();
							
							try {
								// 调用下单API
								const result = await cartApi.placeOrder({
									cartItemIds: selectedItems.map(item => item.id),
									remarks: remarks
								});
								
								this.$refs.loadingPopup.close();
								
								if (result && result.data && result.data.orderId) {
									this.orderId = result.data.orderId;
									
									uni.showToast({
										title: '订单已提交',
										icon: 'success',
										success: () => {
											// 清空已下单的商品
											this.removeOrderedItems(selectedItems);
											
											// 跳转到订单确认页
											setTimeout(() => {
												uni.navigateTo({
													url: `/pages/order/confirmation?orderId=${this.orderId}`
												});
											}, 1000);
										}
									});
								} else {
									throw new Error('提交订单失败');
								}
							} catch (error) {
								this.$refs.loadingPopup.close();
								uni.showToast({
									title: error.message || '下单失败',
									icon: 'none'
								});
							}
						}
					}
				});
			},
			
			// 辅助方法：移除已下单的商品
			async removeOrderedItems(orderedItems) {
				const orderedIds = orderedItems.map(item => item.id);
				
				// 从购物车中移除已下单的商品
				this.cartItems = this.cartItems.filter(item => !orderedIds.includes(item.id));
			},
			
			checkout() {
				// 目前结算功能与下单功能相同
				this.placeOrder();
			},
			
			goShopping() {
				uni.switchTab({
					url: '/pages/list/list'
				});
			},
			
			// 图片预览功能
			previewImage(url) {
				if (!url) return;
				
				uni.previewImage({
					urls: [url],
					current: url,
					indicator: 'number',
					loop: false,
					longPressActions: {
						itemList: ['保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮');
						},
						fail: function(err) {
							console.log(err);
						}
					}
				});
			},
			
			// 下载并打开文件
			downloadAndOpenFile(fileID) {
				this.loadingText = '正在下载文件...';
				this.$refs.loadingPopup.open();
				
				console.log("fileID")
				console.log(fileID)
				wx.cloud.downloadFile({
					fileID: fileID,
					success: (res) => {

						this.$refs.loadingPopup.close();
											
						console.log('res.tempFilePath')
						console.log(res.tempFilePath)

						// 保存成功
						uni.showToast({ 
							title: "文件已保存",
							duration: 1500 
						});
						
						setTimeout(() => {
							// 打开文档查看
							uni.openDocument({
								filePath: res.tempFilePath,
								showMenu: true,
								success: () => {
									console.log('打开文档成功');
								},
								fail: (err) => {
									console.error('打开文档失败', err);
									uni.showToast({
										title: '无法打开此类型文件',
										icon: 'none'
									});
								}
							});
						}, 1500);
					},
					fail: (err) => {
						this.$refs.loadingPopup.close();
						console.error('下载文件失败', err);
						// 提取错误信息
						const errMsg = err.errMsg || JSON.stringify(err) || '未知错误';
						uni.showToast({
							title: '下载失败: ' + errMsg,
							icon: 'none',
							duration: 3000
						});
					}
				});
			},
			
			// 跳转到商品详情页
			goToProductDetail(productId) {
				if (!productId) {
					uni.showToast({
						title: '商品ID不存在',
						icon: 'none'
					});
					return;
				}
				
				uni.navigateTo({
					url: `/pages/product/detail?id=${productId}`
				});
			},
			
			closeSharePopup() {
				this.$refs.sharePopup.close(); // 使用close方法关闭弹窗
			},
		}
	}
</script>

<style>
	.cart-container {
		min-height: 100vh;
		background-color: #f5f5f5;
		padding-bottom: 180rpx;  /* 增加底部空间 */
	}
	
	.cart-list {
		background-color: #ffffff;
		padding: 0;
	}
	
	.cart-item {
		display: flex;
		align-items: center;
		padding: 20rpx 24rpx;
		position: relative;
		border-bottom: 1rpx solid rgba(220, 200, 165, 0.3);
	}
	
	.product-image {
		width: 120rpx;
		height: 120rpx;
		margin-right: 20rpx;
		flex-shrink: 0;
	}
	
	.product-detail {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		min-width: 0;
		padding-right: 10rpx;
	}
	
	.product-name {
		font-size: 28rpx;
		color: #282828;
		margin-bottom: 10rpx;
		font-weight: inherit;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	
	.price-container, .code-container {
		display: flex;
		align-items: center;
		margin-bottom: 8rpx;
	}
	
	.price-label, .code-label {
		font-size: 24rpx;
		color: #282828;
		font-weight: inherit;
	}
	
	.separator {
		font-size: 24rpx;
		color: #dcc8a5;
		margin: 0 4rpx;
		font-weight: inherit;
	}
	
	.product-price {
		font-size: 24rpx;
		color: #282828;
		margin-left: 4rpx;
		font-weight: inherit;
	}
	
	.product-code {
		font-size: 24rpx;
		color: #282828;
		margin-left: 4rpx;
		font-weight: inherit;
	}
	
	.delete-btn {
		width: 40rpx;
		height: 40rpx;
		line-height: 40rpx;
		text-align: center;
		font-size: 36rpx;
		color: #333;
	}
	
	/* 自定义复选框样式 */
	.custom-checkbox {
		width: 25rpx;
		height: 25rpx;
		border: 1px solid #282828;
		margin-right: 20rpx;
		background-color: #ffffff;
		flex-shrink: 0;
		position: relative;
	}
	
	/* 选中状态样式 */
	.custom-checkbox.selected {
		background-color: #dcc8a5;
		border-color: #282828;
	}
	
	/* 操作按钮区样式 */
	.action-buttons {
		display: flex;
		justify-content: space-between;
		padding: 24rpx 30rpx;
		background-color: #ffffff;
		margin-bottom: 20rpx;
		position: sticky;
		top: 0;
		left: 0;
		right: 0;
		z-index: 9;
	}
	
	.btn-outline {
		height: 60rpx;
		line-height: 60rpx;
		border: 1.5px solid #dcc8a5;
		border-radius: 0;
		color: #282828;
		font-size: 28rpx;
		text-align: center;
		background-color: #ffffff;
		flex: 1;
		margin: 0 10rpx;
		font-weight: inherit;
		font-family: inherit;
		transition: transform 0.2s ease;
	}
	
	.btn-outline:first-child {
		margin-left: 0;
	}
	
	.btn-outline:last-child {
		margin-right: 0;
	}
	
	.btn-outline:active {
		transform: scale(0.96);
		background-color: rgba(220, 200, 165, 0.1);
	}
	
	.empty-cart {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 200rpx;
	}
	
	.empty-image {
		width: 200rpx;
		height: 200rpx;
		margin-bottom: 20rpx;
	}
	
	.empty-text {
		font-size: 28rpx;
		color: #333;
		margin-bottom: 30rpx;
	}
	
	.go-shopping-btn {
		width: 200rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		background-color: #F3B250;
		color: #fff;
		border-radius: 40rpx;
		font-size: 28rpx;
	}
	
	.cart-footer {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 100rpx;
		background-color: #fff;
		display: flex;
		align-items: center;
		padding: 0 20rpx;
		z-index: 10;
		box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
	}
	
	.select-all {
		display: flex;
		align-items: center;
		height: 70rpx;
	}
	
	.total-info {
		flex: 1;
		text-align: right;
		height: 70rpx;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}
	
	.total-price {
		font-size: 36rpx;
		color: #F3B250;
		font-weight: bold;
	}
	
	.checkout-btn {
		height: 70rpx;
		line-height: 70rpx;
		width: 120rpx;
		background-color: #282828;
		color: #fff;
		margin-left: 20rpx;
		font-size: 32rpx;
	}
	
	/* 加载弹窗样式 */
	.loading-box {
		background-color: rgba(0, 0, 0, 0.7);
		border-radius: 10rpx;
		padding: 30rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 200rpx;
	}
	
	.loading-spinner {
		width: 60rpx;
		height: 60rpx;
		border: 4rpx solid #fff;
		border-top: 4rpx solid #F3B250;
		border-radius: 50%;
		animation: spin 1s linear infinite;
		margin-bottom: 20rpx;
	}
	
	.loading-text {
		color: #fff;
		font-size: 24rpx;
	}
	
	@keyframes spin {
		0% { transform: rotate(0deg); }
		100% { transform: rotate(360deg); }
	}
	
	/* 查看最近分享的货盘按钮样式 */
	.shared-cart-btn {
		position: fixed;
		bottom: 180rpx;
		left: 20rpx;
		right: 20rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #F3B250;
		color: #fff;
		border-radius: 40rpx;
		font-size: 28rpx;
		z-index: 8;
		box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.1);
	}
	
	.shared-cart-icon {
		font-size: 32rpx;
		margin-right: 10rpx;
	}
	
	.share-popup {
		background-color: #FFFFFF;
		border-radius: 20rpx 20rpx 0 0;
		padding: 30rpx 30rpx 0 30rpx; /* Remove bottom padding */
		margin-bottom: 0; /* Ensure no bottom margin */
	}
	
	/* Customize the share action buttons */
	.share-action-btn {
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		border-top: 1px solid #eee;
		color: #333;
		margin-bottom: 0; /* Ensure no bottom margin */
		border-radius: 0; /* Remove any rounding */
	}
	
	.share-action-btn::after {
		border: none;
	}
	
	/* Add extra space below the last action button for a clean look */
	.share-action-btn:last-child {
		margin-bottom: 0;
		padding-bottom: constant(safe-area-inset-bottom); /* iOS 11.0 */
	}
	
	/* Style overrides for uni-popup to ensure it's flush with the bottom */
	.uni-popup .uni-popup__wrapper.bottom {
		bottom: 0 !important;
		padding-bottom: 0 !important;
	}
</style> 